package com.masterclient.app.modules.aftersale.adapter;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.bean.aftersale.AfterSaleContentItemBean;
import com.eoner.baselib.utils.toast.ToastUtil;
import com.masterclient.app.R;

/**
 * @auther hjian
 * @date 2020/9/28.
 */
public class AfterSaleDetailInfoAdapter extends BaseQuickAdapter<AfterSaleContentItemBean, BaseViewHolder> {

    public AfterSaleDetailInfoAdapter() {
        super(R.layout.item_after_sale_detail_info);
    }
    public AfterSaleDetailInfoAdapter(boolean isSaleOrder) {
        super(R.layout.item_sale_order_detail_info);
    }

    @Override
    protected void convert(BaseViewHolder helper, AfterSaleContentItemBean item) {

        helper.setText(R.id.item_after_sale_detail_title,item.getLabel())
                .setText(R.id.item_after_sale_detail_content, item.getText())
                .setGone(R.id.item_after_sale_detail_copy, item.isCopyable());
        helper.getView(R.id.item_after_sale_detail_copy).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
                cm.setPrimaryClip(ClipData.newPlainText(null, item.getText()));
                ToastUtil.showToast("复制成功");
            }
        });

    }
}
